<?php

namespace App\Http\Requests\System\Position;

use Illuminate\Foundation\Http\FormRequest;

class UpdateResource extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
		$user = $this->user('user');

		if ($user && $user->manager && $user->company_id) {
			return true;
		}
		return false;
    }

	/**
	 * 定义验证规则
	 *
	 * Date: 22/03/2018
	 * @author George
	 * @return array
	 */
	public function rules()
	{
		return [
			'name' => 'required',
			'permissions' => 'required|array'
		];
	}

	/**
	 * 定义验证规则提示
	 *
	 * Date: 22/03/2018
	 * @author George
	 * @return array
	 */
	public function messages()
	{
		return [
			'name.required' => '请输入岗位名称',
			'permissions.array' => '参数必须为权限ID构成的数组',
		];
	}
}
